﻿using System;

namespace Centido.Core
{
    /// <summary>
    ///   An abstart task.
    /// </summary>
    public abstract class TaskBase : ITask
    {
        /// <summary>
        ///   Runs the operation.
        /// </summary>
        public abstract void Run();


        /// <summary>
        ///   Occurs when a diagnostic message from the task is received.
        /// </summary>
        public event EventHandler<TaskMessageReceivedEventArgs> MessageReceived;


        /// <summary>
        ///   Notifies about a received message.
        /// </summary>
        /// <param name="e"></param>
        protected void OnMessageReceived(TaskMessageReceivedEventArgs e)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            if (MessageReceived != null)
                MessageReceived(this, e);
        }
    }
}
